
package com.bgybmi.entity;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

public class UserGroup extends Model<UserGroup>
{
    /**
     * 
     */
    private static final long serialVersionUID = -3724933206673873541L;

    public static final UserGroup me = new UserGroup();

    public Users getUser()
    {
        return Users.me.findById(Integer.parseInt(getNumber("user_id")+""));
    }

    public Group getRole()
    {
        return Group.me.findById(Integer.parseInt(getNumber("group_id")+""));
    }

    public UserGroup findByUserId(int number)
    {
        return me.findFirst("select * from usergroup  where user_id=?", number);
    }

    public Page<UserGroup> findByRoleId(int pageNumber, int pageSize,
            int role_id)
    {
        return paginate(pageNumber, pageSize, "select *",
                "from usergroup where role_id=?", role_id);
    }

}
